/**
 * Created by lanouhn on 17/7/18.
 */

import java.io.DataInputStream;
        import java.io.File;
        import java.io.FileOutputStream;
        import java.io.IOException;
        import java.net.URL;

public class javaImage {
    public javaImage() {
    }

    public static void main(String[] args) throws IOException {
        String imageUrl = "http://img.mp.itc.cn/upload/20161209/ca6dc59ffe51482daa4a469fa1a79f12_th.jpeg";
        URL url = new URL(imageUrl);
        DataInputStream dis = new DataInputStream(url.openStream());
        String newImageName = "/Users/lanouhn/Desktop/1.jpg";
        FileOutputStream fos = new FileOutputStream(new File(newImageName));
        byte[] buffer = new byte[1024];

        int length;
        while((length = dis.read(buffer)) > 0) {
            fos.write(buffer, 0, length);
        }

        dis.close();
        fos.close();
    }
}
